package com.example.gymmanagebackend.service.impl;

import com.example.gymmanagebackend.mapper.CourseReservationMapper;
import com.example.gymmanagebackend.pojo.CourseReservation;
import com.example.gymmanagebackend.service.CourseReservationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class CourseReservationServiceImpl implements CourseReservationService {

    @Autowired
    private CourseReservationMapper courseReservationMapper;

    @Override
    public int addCourseReservation(CourseReservation reservation) {
        return courseReservationMapper.addCourseReservation(reservation);
    }

    @Override
    public List<CourseReservation> getCourseReservationsByUsername(String username) {
        return courseReservationMapper.getCourseReservationsByUsername(username);
    }
@Override
    public int deleteCourseReservationByCondition(String courseName, String reservationTime) {
        return courseReservationMapper.deleteCourseReservationByCondition(courseName, reservationTime);
    }
    public boolean isCourseReservationExists(String username, String courseName, String reservationTime, Date reservationDate) {
        int count = courseReservationMapper.checkCourseReservationExists(username, courseName, reservationDate);
        return count > 0;
    }
    @Override
    public List<CourseReservation> getAllCourseReservations() {
        return courseReservationMapper.getAllCourseReservations();
    }

    @Override
    public List<CourseReservation> getCourseReservationCount() {
        return courseReservationMapper.getCourseReservationCount();
    }

    @Override
    public List<CourseReservation> getCourseGenderDistribution() {
        return courseReservationMapper.getCourseGenderDistribution();
    }
}